package Text4;

import java.util.*;

public class Main {
    static int N = 20, n;
    static boolean[] p = new boolean[N];
    static boolean[] p1 = new boolean[N];
    static boolean[] p2 = new boolean[N];
    static char[][] g = new char[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            Arrays.fill(g[i], '.');
        }
        dfs(0);
    }

    private static void dfs(int u) {
        if (u == n) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    System.out.print(g[i][j]);
                }
                System.out.println();
            }
            System.out.println();
        }
        for (int i = 0; i < n; i++) {
            if (!p[i] && !p1[i + u] && !p2[n - u + i]) {
                p[i] = p1[i + u] = p2[n - u + i] = true;
                g[u][i] = 'Q';
                dfs(u + 1);
                p[i] = p1[i + u] = p2[n - u + i] = false;
                g[u][i] = '.';
            }
        }
    }
}
